package com.jueban.Vo;

import com.jueban.model.ApplyOfIP;
import com.jueban.model.ApplyReward;
import com.jueban.model.RewardState;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Getter
@Setter
public class ApplyRewardVo extends ResultVo {

    private Integer id;

    private ApplyOfIPVo applyOfIP;

    private ApplyOfIPPreview applyOfIPPreview;

    private SuggestVo departmentSuggest;

    private SuggestVo academicSuggest;

    private SuggestVo leaderSuggest;

    private RewardState state;

    private int reward;

    private UserVo user;

    private Date createDate;

    @Data
    private class ApplyOfIPPreview {

        Integer id;
        String ipName;
        String finallyIpName;
        String applicant;
        Date createTime;

    }

    public ApplyRewardVo(ApplyReward applyReward) {
        setProperties(applyReward);
    }

    public ApplyRewardVo() {
    }

    public void setProperties(ApplyReward applyReward) {
        this.id = applyReward.getId();
        this.reward = applyReward.getId();
        this.state = applyReward.getSate();
        applyOfIP = new ApplyOfIPVo(applyReward.getApplyOfIP());
        departmentSuggest = new SuggestVo(applyReward.getDepartmentSuggest());
        academicSuggest = new SuggestVo(applyReward.getAcademicSuggest());
        leaderSuggest = new SuggestVo(applyReward.getLeaderSuggest());
        user = new UserVo(applyReward.getUser());
        this.createDate = applyReward.getCreateDate();
    }

    public void setPreviewProperties(ApplyReward applyReward){
        this.id = applyReward.getId();
        this.reward = applyReward.getId();
        this.createDate = applyReward.getCreateDate();
        applyOfIPPreview = new ApplyOfIPPreview();
        ApplyOfIP applyOfIP = applyReward.getApplyOfIP();
        applyOfIPPreview.setApplicant(applyOfIP.getApplicant().getName());
        applyOfIPPreview.setCreateTime(applyOfIP.getCreateTime());
        applyOfIPPreview.setId(applyOfIP.getId());
        applyOfIPPreview.setFinallyIpName(applyOfIP.getFinallyIPName());
    }
}
